import {get, post, del, put} from '@/utils/request'

export const addWorkOrder = (data) => {
  return post('/order/order-client/api/workOrderInfo/add', data)
}

export const updateWorkOrder = (id, data) => {
  return put(`/order/order-client/api/workOrderInfo/update/${id}`, data)
}
export const changeWorkOrderStatus = (id, status) => {
  return put(`/order/order-client/api/workOrderInfo/changeStatus/${id}?status=${status}`)
}
export const deleteWorkOrder = (id) => {
  return del(`/order/order-client/api/workOrderInfo/del/${id}`)
}

export const getWorkOrderDetail = (id) => {
  return get(`/order/order-client/api/workOrderInfo/get/${id}`)
}

export const getWorkOrders = (params) => {
  const queryString = new URLSearchParams(params).toString()
  return get(`/order/order-client/api/workOrderInfo/list?${queryString}`)
}
export const getWorkOrderStatistic = (data) => {
  return post('/order/order-client/api/workOrderInfo/statistic', data)
}


export const getUnassignedWorkOrders = (bo, pageNo = 1, pageSize = 10) => {


  return post(`/order/order-client/api/workOrderInfo/unassigned/list?pageNo=${pageNo}&pageSize=${pageSize}`, bo);
}

export const dispatchWorkOrder = (dispatchBO) => {
  return post('/order/order-client/api/workOrderInfo/dispatch', dispatchBO);
}

export const autoDispatchWorkOrder = (bo) => {
  return post('/order/order-client/api/autoDispatch/execute', bo)
}

export const archiveAllCompleted = () => {
  return post('/order/order-client/api/workOrderInfo/archiveAllCompleted');
}
